//求单谷谷值，一次维护两个点

//(二次函数的 a > 0,开口向上)
//f(l) > f(r) -> l = lmid + 1;
//f(l) <= f(r) -> r = rmid - 1;
while (l < r) 
{
    int midl = l + (r - l) / 3;
    int midr = r - (r - l) / 3;
    if (check(midl) > check(midr))
        l = midl + 1;
    else
        r = midr - 1;
} 
ans = min(ans,check(l));

//(二次函数的 a < 0,开口向下)
//f(l) < f(r) -> l = lmid + 1;
//f(l) >= f(r) -> r = rmid - 1;
while (l < r) 
{
    int midl = l + (r - l) / 3;
    int midr = r - (r - l) / 3;
    if (check(midl) < check(midr))
        l = midl + 1;
    else
        r = midr - 1;
}
ans = min(ans,check(l));